package com.cn.web.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;

import com.cn.domain.Product;

public class TipNameServlet extends BaseServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//response.setContentType("text/html;charset=utf-8");
		String tipname = request.getParameter("tipname");
		System.out.println(tipname);
		List<Product> list = ps.getProductByTipName(tipname);
		System.out.println(list);
		JSONArray ja = JSONArray.fromObject(list);
		System.out.println(ja);
		response.getWriter().write(ja.toString());
	}
}
